//
//  ListSecondTableViewCell.m
//  Travel
//
//  Created by dllo on 15/9/30.
//  Copyright (c) 2015年 0. All rights reserved.
//

#import "ListSecondTableViewCell.h"
#define WIDTH  [[UIScreen mainScreen]bounds].size.width
#define HEIGHT [[UIScreen mainScreen]bounds].size.height
#define PHEIGHT [[UIScreen mainScreen]bounds].size.height/667.00

@implementation ListSecondTableViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(8, 5, (375 - 25) *XWIDTH, 200 * XHIGHT)];
    self.myImageView.layer.masksToBounds = YES;
    self.myImageView.layer.cornerRadius = 8.0;
    self.myImageView.layer.borderColor = [[UIColor whiteColor] CGColor];
    [self.contentView addSubview:self.myImageView];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.053*WIDTH, 5, (375 - 25) *XWIDTH, 0.045*HEIGHT)];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17*PHEIGHT];

    [self.contentView addSubview:self.titleLabel];
    
    self.dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.067*WIDTH, 0.052*HEIGHT, 0.213*WIDTH, 0.03*HEIGHT)];
    self.dateLabel.font = [UIFont systemFontOfSize:13*PHEIGHT];
    self.dateLabel.textColor = [UIColor whiteColor];
    self.dateLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13*PHEIGHT];

    [self.contentView addSubview:self.dateLabel];
    
    self.dayCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.293*WIDTH, 0.052*HEIGHT, 0.107*WIDTH, 0.03*HEIGHT)];
    self.dayCountLabel.font = [UIFont systemFontOfSize:13*PHEIGHT];
    self.dayCountLabel.textColor = [UIColor whiteColor];
    self.dayCountLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13*PHEIGHT];

    [self.contentView addSubview:self.dayCountLabel];
    
    self.visitCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.4*WIDTH, 0.052*HEIGHT, 0.32*WIDTH, 0.03*HEIGHT)];
    self.visitCountLabel.font = [UIFont systemFontOfSize:13*PHEIGHT];
    self.visitCountLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13*PHEIGHT];

    self.visitCountLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.visitCountLabel];
    
    self.placeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.067*WIDTH, 0.09*HEIGHT, 0.747*WIDTH, 0.03*HEIGHT)];
    self.placeLabel.font = [UIFont systemFontOfSize:13*PHEIGHT];
    self.placeLabel.textColor = [UIColor whiteColor];
    self.placeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13*PHEIGHT];

    [self.contentView addSubview:self.placeLabel];
    
    self.autorImage = [[UIImageView alloc]initWithFrame:CGRectMake(0.08*WIDTH, 0.237*HEIGHT, 0.053*WIDTH, 0.03*HEIGHT)];
    [self.contentView addSubview:self.autorImage];
    self.autorImage.layer.masksToBounds = YES;
    self.autorImage.layer.cornerRadius = 10;
    
    self.autorNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.167*WIDTH, 0.227*HEIGHT, 0.533*WIDTH, 0.045*HEIGHT)];
    self.autorNameLabel.font = [UIFont systemFontOfSize:13*PHEIGHT];
    self.autorNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13*PHEIGHT];

    [self.contentView addSubview:self.autorNameLabel];
    self.autorNameLabel.textColor = [UIColor whiteColor];
}


-(void)setModel2:(Model2 *)model2
{
    _model2 = model2;
    
    [self.myImageView sd_setImageWithURL:[NSURL URLWithString:_model2.cover_image_default] placeholderImage:[UIImage imageNamed:@"1.jpg"]];
    self.titleLabel.text = _model2.name;
    self.autorNameLabel.text = [NSString stringWithFormat:@"by%@",_model2.autorName];
    [self.autorImage sd_setImageWithURL:[NSURL URLWithString:_model2.avatar_m] placeholderImage:[UIImage imageNamed:@"1.jpg"]];
    self.dateLabel.text = _model2.last_day;
    self.dayCountLabel.text = [NSString stringWithFormat:@"%ld天",_model2.day_count];
    self.visitCountLabel.text = [NSString stringWithFormat:@"%ld次浏览",_model2.view_count];
    self.placeLabel.text = _model2.popular_place_str;
}


@end
